<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>医院诊疗系统</title>
  <link rel="stylesheet" href="../css/layui.css">
  <script src="../layui.js"></script>
  <script src="../js/jquery-3.5.1.js"></script>

</head>
<body>
    <div class="layui-layout layui-layout-admin">
    <!-- 头部区域（可配合layui 已有的水平导航） -->
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">医院诊疗系统</div>
        
        <ul class="layui-nav layui-layout-left">
        <!-- 移动端显示 -->
        <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
            <i class="layui-icon layui-icon-spread-left"></i>
        </li>
        
        <li class="layui-nav-item layui-hide-xs layui-this"><a href="drug_in_storage.html">药库管理</a></li>
      </ul>
  
  
  
      <!-- 右上角导航栏 -->
      <ul class="layui-nav layui-layout-right">
          
        <div class="layui-nav-item layui-hide layui-show-md-inline-block" style=" text-align: center; 
          display: inline-block; line-height: 42px; height: 42px; width: 25px; ">
          <div id="red-spot" style="position:absolute ;top: 1px; right: -7px; width: 4px; height: 4px; border: 0.5px solid red;
          background-color: red; border-radius: 50%;"></div>
          <i id="notice" class="layui-icon layui-icon-notice" style="font-size: 20px; color:rgba(255, 255, 255, .7);"></i>
          <!-- <span class="layui-badge-dot" style=" border: 0.5px; position: relative;top:-62px; right: -15px; "></span> -->
        </div>
        <li class="layui-nav-item layui-hide layui-show-md-inline-block">
          <a href="javascript:;">
            <img src="../image/gly.jpg" class="layui-nav-img">
            药库管理员
          </a>
          <dl class="layui-nav-child">
            <dd><a href="">修改密码</a></dd>
            <dd><a id="edit">编辑信息</a></dd>
            <dd><a href="">退出登录</a></dd>
          </dl>
        </li>
        
      </ul>
      <!-- 右上角导航栏 -->
      
    </div>
    <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
        
          <ul class="layui-nav layui-nav-tree" lay-filter="test">
            <li class="layui-nav-item layui-nav-itemed">
              <a href="drug_in_storage.html" class="layui-this" >药品入库</a>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
              <a href="drug_out_storage.html">药品出库</a>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
              <a href="drug_query.html" >药品查询</a>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
              <a href="drug_adjust_price.html">药品调价</a>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
              <a href="drug_delete.html">药品删除</a>
            </li>
          </ul>

  
        </div>
      </div>
     <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
    
        <!-- 内容主体区域 -->
    <div class="layui-body" style="padding: 15px;">
      <!-- 面包屑 -->
    
      <div style=" padding: 15px;  background-color: #ffffff; border: solid #eeeeee 1px; box-shadow: inset 0 0 10px rgba(255, 255, 227, 0.925);">
        <fieldset class="layui-elem-field layui-field-title" style="margin: 0; border-top: none; padding: 0;height: 25px;line-height: 25px;">
          <span class="layui-breadcrumb" >
              <a href="/">药库管理</a>
              <a><cite>药品入库</cite></a>
          </span>
        </fieldset>
      </div>
    
      <!-- 面包屑 -->

            <blockquote class="layui-elem-quote" style="margin-top: 10px;">
              药品库
            </blockquote>

            <!-- 由id渲染表格 -->
            <table class="layui-hide" id="test" lay-filter="test"></table>

            <blockquote class="layui-elem-quote" style="margin-top: 10px;">
              新增药品
            </blockquote>


            <!-- 新增药品 -->
            <div id="testdemo" style="margin: 20px 20px;padding: 20px 20px;border: 1px solid #009688;">
              <form class="layui-form  layui-form-pane" style="height:100%;" id="formPreviewForm"
                lay-filter="formPreviewForm">
                <div id="grid_6" class="layui-form-item layui-row grid " data-id="grid_6" data-tag="grid"
                  data-index="0">
                  <div class="layui-col-md4 widget-col-list columngrid_60" data-index="0" data-parentindex="0">
                    <div id="yp_id" class="layui-form-item " data-id="yp_id" data-tag="input" data-index="0"><label
                        class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;">*</span>药品代码:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_id" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="required"
                          style="width:100%"></div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_61" data-index="1" data-parentindex="0">
                    <div id="yp_name" class="layui-form-item " data-id="yp_name" data-tag="input" data-index="0"><label
                        class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;">*</span>药品名称:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_name" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="required"
                          style="width:100%"></div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_310" data-index="0" data-parentindex="5">
                    <div id="yp_count" class="layui-form-item " data-id="yp_count" data-tag="input" data-index="0">
                      <label class="layui-form-label layui-form-required" style="width: 110px;">
                        <span style="color:red;">*</span>药品数量:</label>
                      <div class="layui-input-block" style="margin-left: 110px">
                        <input name="yp_count" value="" placeholder="请输入" class="layui-input" lay-vertype="tips"
                          lay-verify="required|number" style="width:100%">
                      </div>
                    </div>
                  </div>




                </div>
                <div id="grid_11" class="layui-form-item layui-row grid " data-id="grid_11" data-tag="grid"
                  data-index="1">
                  <div class="layui-col-md4 widget-col-list columngrid_110" data-index="0" data-parentindex="1">
                    <div id="yp_form" class="layui-form-item " data-id="yp_form" data-tag="input" data-index="0"><label
                        class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;">*</span>剂型:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_form" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="required"
                          style="width:100%"></div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_111" data-index="1" data-parentindex="1">
                    <div id="yp_producer" class="layui-form-item " data-id="yp_producer" data-tag="input"
                      data-index="0">
                      <label class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;">*</span>生产产家:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_producer" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="required"
                          style="width:100%"></div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_112" data-index="2" data-parentindex="1">
                    <div id="yp_company" class="layui-form-item " data-id="yp_company" data-tag="input" data-index="0">
                      <label class="layui-form-label " style="width: 110px;"><span style="color:red;"></span>单位:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_company" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="" style="width:100%">
                      </div>
                    </div>
                  </div>
                </div>
                <div id="grid_15" class="layui-form-item layui-row grid " data-id="grid_15" data-tag="grid"
                  data-index="2">
                  <div class="layui-col-md4 widget-col-list columngrid_150" data-index="0" data-parentindex="2">
                    <div id="yp_price" class="layui-form-item " data-id="yp_price" data-tag="input" data-index="0">
                      <label class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;">*</span>单价:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_price" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="required"
                          style="width:100%"></div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_151" data-index="1" data-parentindex="2">
                    <div id="yp_mcompany" class="layui-form-item " data-id="yp_mcompany" data-tag="input"
                      data-index="0">
                      <label class="layui-form-label " style="width: 110px;"><span
                          style="color:red;"></span>最小单位:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_mcompany" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="" style="width:100%">
                      </div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_152" data-index="2" data-parentindex="2">
                    <div id="yp_coef" class="layui-form-item " data-id="yp_coef" data-tag="input" data-index="0"><label
                        class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;"></span>系数:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_coef" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify=""
                          style="width:100%"></div>
                    </div>
                  </div>
                </div>
                <div id="grid_19" class="layui-form-item layui-row grid " data-id="grid_19" data-tag="grid"
                  data-index="3">
                  <div class="layui-col-md4 widget-col-list columngrid_190" data-index="0" data-parentindex="3">
                    <div id="yp_pycode" class="layui-form-item " data-id="yp_pycode" data-tag="input" data-index="0">
                      <label class="layui-form-label " style="width: 110px;"><span
                          style="color:red;"></span>拼音码:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_pycode" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="" style="width:100%">
                      </div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_191" data-index="1" data-parentindex="3">
                    <div id="yp_wbcode" class="layui-form-item " data-id="yp_wbcode" data-tag="input" data-index="0">
                      <label class="layui-form-label " style="width: 110px;"><span
                          style="color:red;"></span>五笔码:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_wbcode" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="" style="width:100%">
                      </div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_192" data-index="2" data-parentindex="3">
                    <div id="yp_anumber" class="layui-form-item " data-id="yp_anumber" data-tag="input" data-index="0">
                      <label class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;">*</span>批准文号:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_anumber" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="required"
                          style="width:100%"></div>
                    </div>
                  </div>
                </div>
                <div id="grid_23" class="layui-form-item layui-row grid " data-id="grid_23" data-tag="grid"
                  data-index="4">
                  <div class="layui-col-md4 widget-col-list columngrid_230" data-index="0" data-parentindex="4">
                    <div id="yp_insurance" class="layui-form-item " data-id="yp_insurance" data-tag="input"
                      data-index="0">
                      <label class="layui-form-label " style="width: 110px;"><span
                          style="color:red;"></span>医保可报:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_insurance" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="" style="width:100%">
                      </div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_231" data-index="1" data-parentindex="4">
                    <div id="yp_category" class="layui-form-item " data-id="yp_category" data-tag="input"
                      data-index="0">
                      <label class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;"></span>账目类别:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_category" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify=""
                          style="width:100%"></div>
                    </div>
                  </div>
                  <div class="layui-col-md4 widget-col-list columngrid_232" data-index="2" data-parentindex="4">
                    <div id="yp_ratio" class="layui-form-item " data-id="yp_ratio" data-tag="input" data-index="0">
                      <label class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;"></span>加成比:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="yp_ratio" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify=""
                          style="width:100%"></div>
                    </div>
                  </div>
                </div>
                <div id="grid_31" class="layui-form-item layui-row grid " data-id="grid_31" data-tag="grid"
                  data-index="5">
                 

                  <div class="layui-col-md4 widget-col-list columngrid_62" data-index="2" data-parentindex="0">
                    <div id="input_9" class="layui-form-item " data-id="input_9" data-tag="input" data-index="0"><label
                        class="layui-form-label layui-form-required" style="width: 110px;"><span
                          style="color:red;">*</span>药品规格:</label>
                      <div class="layui-input-block" style="margin-left: 110px"><input name="input_9" value=""
                          placeholder="请输入" class="layui-input" lay-vertype="tips" lay-verify="required"
                          style="width:100%"></div>
                    </div>
                  </div>


                  <div class="layui-col-md4 widget-col-list columngrid_311" data-index="1" data-parentindex="5"></div>
                  <div class="layui-col-md4 widget-col-list columngrid_312" data-index="2" data-parentindex="5"></div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-input-block"><button type="submit" class="layui-btn" lay-submit=""
                      lay-filter="demo1">添加</button><button type="reset" class="layui-btn layui-btn-primary">重置</button>
                  </div>
                </div>
              </form>
            </div>

            <!-- 新增药品 -->
      <!-- 新增药品提交表单 -->
      <script>
        $(function () {
          layui.use('form', function(){
            var form = layui.form;
            //监听提交
            form.on('submit(demo1)', function(data){

              console.log(data.elem); //被执行事件的元素DOM对象，一般为button对象
              console.log(data.form); //被执行提交的form对象，一般在存在form标签时才会返回
              console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
              $.ajax({
                url: "/Drug/insertDrug",
                type: "post",
                contentType:'application/json;charset=UTF-8',
                data: JSON.stringify(data.field),
                dataType: "json",
                success: function(data) {
                  console.log(data)
                  window.location.reload()
                  // let index = parent.layer.getFrameIndex(window.name)
                  // parent.layer.close(index)
                  // // console.log(data)
                  // parent.location.reload()
                },
                error: function(data) {
                  console.log('错误')
                  window.location.reload()
                  // let index = parent.layer.getFrameIndex(window.name)
                  // parent.layer.close(index)
                  // // console.log(data)
                }

              })

              return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
          });
        })

      </script>

      <!-- 新增药品提交表单 -->

    </div>

      <!-- 主体 -->

    </div>





    <!-- // 表格处理 -->

    <script type="text/html" id="toolbarDemo">
      <div class="layui-btn-container">
        <div style="padding-right:30px; display:inline-block ">
          <input class=" layui-btn-sm" type="text"  name="" id="drug_id_text" placeholder="搜索药品ID" >
          <a class="layui-btn layui-btn-sm" style="margin:0 0 9.6px 1em ;" id="drug_id" >搜索</a>
        </div>

        <input class=" layui-btn-sm" type="text"  name="" id="drug_name_text" placeholder="搜索药品名称" >
        <a class="layui-btn layui-btn-sm" style="margin:0 0 9.6px 1em ;" id="drug_name" >搜索</a>
      </div>
    </script>

    <script type="text/html" id="barDemo">
      <a class="layui-btn layui-btn-xs" lay-event="edit">添加药品库存</a>
    </script>


    <script>
      var a;
      var table_data = []

      layui.use('table', function(){
        var table = layui.table;

        $.ajax({
          url: "/Drug/getAll",
          type: "get",
          contentType: 'application/json;charset=UTF-8',
          // data: JSON.stringify(data.field),
          // dataType: "json",
          success: function (data) {

            for (var i = 0; i < data.length; i++) {
              let insurance = '否'
              if (data[i]['yp_insurance'] === 1) {
                insurance = '是'
              }
              let temp_data = {
                "yp_id": data[i]['yp_id'],
                "yp_name": data[i]['yp_name'],
                "yp_count": data[i]['yp_amount'],
                "yp_standard": data[i]['yp_standard'],
                "yp_form": data[i]['yp_form'],
                "yp_producer": data[i]['yp_producer'],
                "yp_company": data[i]['yp_company'],
                "yp_price": data[i]['yp_uprice'],
                "yp_mcompany": data[i]['yp_mcompany'],
                "yp_coef": data[i]['yp_coef'],
                "yp_pycode": data[i]['yp_pycode'],
                "yp_wbcode": data[i]['yp_wbcode'],
                "yp_anumber": data[i]['yp_anumber'],
                "yp_insurance": insurance,
              }

              table_data.push(temp_data)

              console.log(table_data)
              table.reload("test", {
                where: {
                  data: table_data
                }
              })

              // let index = parent.layer.getFrameIndex(window.name)
              // parent.layer.close(index)
              // // console.log(data)
              // parent.location.reload()
            }
          }
        })

        $(document).on('click','#drug_id',function(){

          var val= $(this).parent().find("#drug_id_text").val();
          console.log(val);

          $.ajax({
            url: "/Drug/getDrugById?id="+val,
            type: "get",
            contentType: 'application/text;charset=UTF-8',
            success: function (data) {
              console.log(data)
              let temp_length = table_data.length
              for (let i = 0; i < temp_length ; i++) {
                table_data.pop()
              }

              let insurance = '否'
              if (data['yp_insurance'] === 1) {
                insurance = '是'
              }
              let temp_data = {
                "yp_id": data['yp_id'],
                "yp_name": data['yp_name'],
                "yp_count": data['yp_amount'],
                "yp_standard": data['yp_standard'],
                "yp_form": data['yp_form'],
                "yp_producer": data['yp_producer'],
                "yp_company": data['yp_company'],
                "yp_price": data['yp_uprice'],
                "yp_mcompany": data['yp_mcompany'],
                "yp_coef": data['yp_coef'],
                "yp_pycode": data['yp_pycode'],
                "yp_wbcode": data['yp_wbcode'],
                "yp_anumber": data['yp_anumber'],
                "yp_insurance": insurance,
              }

              table_data.push(temp_data)

              console.log(table_data)
              table.reload("test", {
                page: {
                  curr:1
                },
                where: {
                  data: table_data
                }
              })
              console.log('after')


            },
          })
        });
        $(document).on('click','#drug_name',function(){

          var val= $(this).parent().find("#drug_name_text").val();
          console.log(val);

          $.ajax({
            url: "/Drug/getDrugByName?name="+val,
            type: "get",
            contentType: 'application/text;charset=UTF-8',
            success: function (data) {
              console.log(data)
              let temp_length = table_data.length
              for (let i = 0; i < temp_length ; i++) {
                table_data.pop()
              }

              let insurance = '否'
              if (data['yp_insurance'] === 1) {
                insurance = '是'
              }
              let temp_data = {
                "yp_id": data['yp_id'],
                "yp_name": data['yp_name'],
                "yp_count": data['yp_amount'],
                "yp_standard": data['yp_standard'],
                "yp_form": data['yp_form'],
                "yp_producer": data['yp_producer'],
                "yp_company": data['yp_company'],
                "yp_price": data['yp_uprice'],
                "yp_mcompany": data['yp_mcompany'],
                "yp_coef": data['yp_coef'],
                "yp_pycode": data['yp_pycode'],
                "yp_wbcode": data['yp_wbcode'],
                "yp_anumber": data['yp_anumber'],
                "yp_insurance": insurance,
              }

              table_data.push(temp_data)

              console.log(table_data)
              table.reload("test", {
                where: {
                  data: table_data
                }
              })

            },
          })
        });

        table.render({
          elem: '#test'
          // ,url:'mods/table/user/a.json'   //数据来源接口

          ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
          ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
            title: '提示'
            ,layEvent: 'LAYTABLE_TIPS'
            ,icon: 'layui-icon-tips'
          }]
          ,title: '用户数据表'
          ,cols: [
            [  //表头
              {type: 'checkbox', fixed: 'left'}
              ,{field: 'yp_id', title: '药品代码', width:130, sort: true, fixed: 'left' ,align:"center"}
              ,{field: 'yp_name', title: '药品名称', width:100 ,align:"center"}
              ,{field: 'yp_count', title: '药品数量', width:100 ,align:"center"}
              ,{field: 'yp_standard', title: '规格', width:100 ,align:"center"}
              ,{field: 'yp_form', title: '剂型', width: 60 ,align:"center"}
              ,{field: 'yp_producer', title: '生产产家', width:200 ,align:"center"}
              ,{field: 'yp_company', title: '单位', width: 200  ,align:"center"}
              ,{field: 'yp_price', title: '单价', width:110 ,align:"center"}
              ,{field: 'yp_mcompany', title: '最小单位', width:110 ,align:"center"}
              ,{field: 'yp_coef', title: '系数', width:60 ,align:"center"}
              ,{field: 'yp_pycode', title: '拼音码', width:170 ,align:"center"}
              ,{field: 'yp_wbcode', title: '五笔码', width: 150 ,align:"center"}
              ,{field: 'yp_anumber', title: '批准文号', width:110 ,align:"center"}
              ,{field: 'yp_insurance', title: '医保可报', width: 120  ,align:"center"}
              ,{fixed: 'right', width: 140, align:'center', toolbar: '#barDemo'}
            ]
          ]
          ,page: true
          ,data: table_data
          // ,data:[
          //   {
          //     "yp_id": 1320030581,
          //     "yp_name": "拉米夫定片",
          //     "yp_count": "255",
          //     "yp_standard":"	0.1g*14s",
          //     "yp_form": "片剂",
          //     "yp_producer": "葛兰素史克制药(苏州)有限公司",
          //     "yp_company": "葛兰素史克制药(苏州)有限公司",
          //     "yp_price": "￥139.00",
          //     "yp_mcompany": "0.3g",
          //     "yp_coef": "1",
          //     "yp_pycode":"lamifudingpian",
          //     "yp_wbcode": "sdlkfjsd",
          //     "yp_anumber": "H20030581",
          //     "yp_insurance": "否"
          //   }
          // ]

        })





        //监听行工具事件
        table.on('tool(test)', function(obj){
          var data = obj.data;
          //console.log(obj)
          if(obj.event === 'edit'){
            layer.prompt({
              formType: 2,
              value: '320',
              title: '请输入增加的库存:',
              area: ['200px', '20px'] //自定义文本域宽高
            },function(val, index){

              $.ajax({
                url: "/Drug/updateAmount?id="+obj.data['yp_id']+"&amount="+val,
                type: "get",
                contentType: 'application/json;charset=UTF-8',
                // data: JSON.stringify(data.field),
                // dataType: "json",
                success: function (data) {
                  console.log(table_data.length)
                  let temp_length = table_data.length
                  for (let i = 0; i < temp_length ; i++) {
                    table_data.pop()
                  }
                  $.ajax({
                    url: "/Drug/getAll",
                    type: "get",
                    contentType: 'application/json;charset=UTF-8',
                    // data: JSON.stringify(data.field),
                    // dataType: "json",
                    success: function (data) {

                      for (var i = 0; i < data.length; i++) {
                        let insurance = '否'
                        if (data[i]['yp_insurance'] === 1) {
                          insurance = '是'
                        }
                        let temp_data = {
                          "yp_id": data[i]['yp_id'],
                          "yp_name": data[i]['yp_name'],
                          "yp_count": data[i]['yp_amount'],
                          "yp_standard": data[i]['yp_standard'],
                          "yp_form": data[i]['yp_form'],
                          "yp_producer": data[i]['yp_producer'],
                          "yp_company": data[i]['yp_company'],
                          "yp_price": data[i]['yp_uprice'],
                          "yp_mcompany": data[i]['yp_mcompany'],
                          "yp_coef": data[i]['yp_coef'],
                          "yp_pycode": data[i]['yp_pycode'],
                          "yp_wbcode": data[i]['yp_wbcode'],
                          "yp_anumber": data[i]['yp_anumber'],
                          "yp_insurance": insurance,
                        }

                        table_data.push(temp_data)

                        console.log(table_data)
                        table.reload("test", {
                          where: {
                            data: table_data
                          }
                        })

                      }
                    }
                  })
                }
              })

              layer.close(index);
            });
          } else if(obj.event === 'edit'){
            layer.prompt({
              formType: 2
              ,value: data.email
            }, function(value, index){
              obj.update({
                email: value
              });
              layer.close(index);
            });
          }
        });
      });


    </script>


    <!-- // 表格处理 -->






    <!-- 修改信息事件 -->
    <script>
      $("#edit").on('click',function(e){
        //打开窗口
        layer.open({
          type: 2,
          area: ['1000px', '600px'],
          fixed: false, //不固定
          maxmin: true,
          title:"个人信息",
          content: 'edit_information.html'
          // 3.父传子值
          //  success:function(layero, index){
          //       //关键在这，调用子的iframe的方法，进行传参,前两行固定写法
          //       var body = layer.getChildFrame('body', index);
          //       var iframeWin = window[layero.find('iframe')[0]['name']];
          //       var div=$(obj).text();
          //       iframeWin.childIframe(div);    //看这
          //   }
        });
      });

    </script>

</body>
</html>